using UnityEngine;
using System.Collections;

public class Tiro : MonoBehaviour {
	
	public Transform ExplosaoGrande;
	public Transform Tiross;
	public Projector lanca;
	Vector3 tiross;
	float speed = 2.0f;
	bool disparei = false;
	Vector3 vaipraparede = new Vector3(0,0,1);
	float tempo = 0;
	ArrayList listaTiro;
	
	// Use this for initialization
	void Start ()
	{
	
	}
	
	// Update is called once per frame
	void Update ()
	{
		
		
		if(Input.GetKeyDown(KeyCode.A))
		{
			disparei = true;
			tempo++;
			
		}
		if(tempo < 10)
		{
			disparei = false;
			
		}
		else
		{
			disparei = true;
		}
		
		if(disparei)
		{
			transform.Translate(vaipraparede*speed);	                    
		}
		
		//if(Input.anyKeyDown)
		//{
		//	//FogoTiro f = new FogoTiro();
		//	Quaternion rotacao = new Quaternion(transform.position.x, transform.position.y, transform.position.z, 0 );
		//	Instantiate(ExplosaoGrande, transform.position, rotacao);
		//	
		//}
	}
	
	void OnCollisionEnter(Collision collision)
	{
		
		Quaternion rotacao = new Quaternion(transform.position.x, transform.position.y, transform.position.z, 0 );
		Instantiate(ExplosaoGrande, transform.position, rotacao);
		Destroy(collision.gameObject);
		Destroy(this);
		
		
		
		//Quaternion rotacao2 = new Quaternion(transform.position.x,transform.position.y,transform.position.z,0);
		//Instantiate(ExplosaoPequena,transform.position,rotacao2);
		//Destroy(collision.gameObject);
		//Destroy(this);
		
	}
}
